﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports System.Collections.Generic

Imports System.Linq
Imports System.Xml.Linq
Imports GenDotNet.Task.Common
Imports GenDotNet.ObjectModel
Imports <xmlns:orm="http://kadgen.com/KADORM.xsd">
Imports <xmlns:kd="http://kadgen.com/Special.xsd">

Namespace GenInputMetadata
   Public Class StoredProcedureData
      Inherits BaseData
      Implements IStoredProcedureData

      Private mParameters As List(Of ISpParameterData)
      Private mObjectData As IObjectData

      Public Shared Function Load(ByVal objectData As ObjectData, ByVal element As XElement) As StoredProcedureData
         If element Is Nothing Then
            Return Nothing
         End If
         Dim ret = New StoredProcedureData(objectData.RootData, element)
         ret.mObjectData = objectData
         If element IsNot Nothing Then
            ret.mParameters = SpParameterData.Load(ret, From x In element...<orm:Parameter>)
         End If
         Return ret
      End Function

      Private Sub New(ByVal rootData As RootData, _
                      ByVal element As XElement)
         MyBase.New(rootData, element)
      End Sub

      Public ReadOnly Property Name() As String Implements IStoredProcedureData.Name
         Get
            Return Element.@Name
         End Get
      End Property

      Public ReadOnly Property Parameters() As System.Collections.Generic.List(Of ISpParameterData) Implements IStoredProcedureData.Parameters
         Get
            Return mParameters
         End Get
      End Property

      Public ReadOnly Property ObjectData() As IObjectData Implements IStoredProcedureData.ObjectData
         Get
            Return mObjectData
         End Get
      End Property
   End Class

End Namespace
